function [x,fval,residual,exitflag,output,LAMB,JACOBIAN]=optim_fitref_ED_3box(P0,C0,xdata,ydata,yerr,LB,UB)
options=optimset('MaxIter',100,'TolFun',1e-5,'Display','off','TolX',1e-4,'MaxFunEvals',1e6);
[x,fval,residual,exitflag,output,LAMB,JACOBIAN]=lsqcurvefit(@nestedfun,P0,xdata,ydata./yerr,LB,UB,options);
    function y=nestedfun(P0,xdata)      
        y=fitref_ED_3box(P0,C0,xdata)./yerr;
    end
end